package wonder;

import java.io.Serializable;
import java.util.Map;

import wonder.ISWService.BoardSet;
import wonder.ISWService.BoardSide;

/**
 * <p>WonderMap class.</p>
 *
 * @author u211354
 * @version $Id: $
 */
public class Board implements Serializable{
    private static final long serialVersionUID = -8004777883640452123L;
    private BoardSide side;
    private BoardSet fromSet;
    private String name;
    private int steps;
    private boolean available = true;
    private BoardInitialResource initialResource;

    public Board() {
        super();
    }

    /**
     * <p>Constructor for WonderMap.</p>
     *
     * @param side a {@link wonder.ISWService.BoardSide} object.
     * @param fromSet a {@link wonder.ISWService.BoardSet} object.
     * @param name a {@link java.lang.String} object.
     * @param steps a int.
     */
    public Board(BoardSide side, BoardSet fromSet,
            String name,
            int steps) {
        super();
        this.side = side;
        this.fromSet = fromSet;
        this.name = name;
        this.steps = steps;
    }

    public Board(Map<String,Object> w) {
        super();
        name = (String)w.get("name");
        side = BoardSide.valueOf((String)w.get("side"));
        fromSet = BoardSet.valueOf((String)w.get("set"));
        steps = (Integer)w.get("steps");
    }

    /** {@inheritDoc} */
    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer("{ ");
        sb.append(name);
        sb.append(":");
        sb.append(side);
        sb.append(", steps #");
        sb.append(steps);
        sb.append(" set:");
        sb.append(fromSet);
        sb.append(" av:");
        sb.append(available);
        if (initialResource != null) {
            sb.append(" ir:");
            sb.append(initialResource);
        }
        sb.append(" }");
        return sb.toString();
    }

    /**
     * <p>Getter for the field <code>side</code>.</p>
     *
     * @return a {@link wonder.ISWService.BoardSide} object.
     */
    public BoardSide getSide() {
        return side;
    }

    /**
     * <p>Setter for the field <code>side</code>.</p>
     *
     * @param side a {@link wonder.ISWService.BoardSide} object.
     */
    public void setSide(BoardSide side) {
        this.side = side;
    }

    /**
     * <p>Getter for the field <code>name</code>.</p>
     *
     * @return a {@link java.lang.String} object.
     */
    public String getName() {
        return name;
    }

    /**
     * <p>Setter for the field <code>name</code>.</p>
     *
     * @param name a {@link java.lang.String} object.
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * <p>Getter for the field <code>steps</code>.</p>
     *
     * @return a int.
     */
    public int getSteps() {
        return steps;
    }

    /**
     * <p>Setter for the field <code>steps</code>.</p>
     *
     * @param steps a int.
     */
    public void setSteps(int steps) {
        this.steps = steps;
    }

    /**
     * <p>getSet</p>
     *
     * @return a {@link wonder.ISWService.BoardSet} object.
     */
    public BoardSet getSet() {
        return fromSet;
    }

    /**
     * <p>setSet</p>
     *
     * @param fromSet a {@link wonder.ISWService.BoardSet} object.
     */
    public void setSet(BoardSet fromSet) {
        this.fromSet = fromSet;
    }

    public boolean isAvailable() {
        return available;
    }

    public void setAvailable(boolean available) {
        this.available = available;
    }

    public BoardInitialResource getInitialResource() {
        return initialResource;
    }

    public void setInitialResource(BoardInitialResource initialResource) {
        this.initialResource = initialResource;
    }
}
